package com.netflexitysolutions.amazonws.sdb.orm.filter;

import java.io.Serializable;

/**
 * An interface for objects that can filter a set of records based on some criterion. More formally speaking: a unary 
 * predicate that operates on collections of records.
 * 
 * A Filter has a method called accept() that allows us to filter over a set of cached (in-memory) records. The 
 * toSelect() should return Amazon SImpleDB Select query equivalent that would provide the same subset of records
 * from Amazon SimpleDB.
 * 
 * @author netflexity
 */
public interface Filter<T> extends Serializable {

    /**
     * Should this record be excluded from a subset?
     * 
     * @param record
     * @return
     */
    public boolean filter(T record);


    /**
     * What kind of record type we are looking for.
     * The filter will only return results of a certain record type.
     * If this returns null, it means that we could have heterogeneous results.
     */
    public Class<T> getType();
    
    /**
     * @return Amazon SimpleDB Select query. A null
     * value would indicate that we don't know the SQL command. In that
     * case, the filter will have to be applied in-memory.
     */
    public String toSelect();
}
